﻿Public Class PRDPRICE
    Private PRCID = Nothing
    Private PRDCODE = Nothing
    Private MTRGTID = Nothing
    Private STRGTID = Nothing
    Private SBRGTID = Nothing
    Private OPRICE = Nothing
    Private IPRICE = Nothing
    Private STDATE = Nothing
    Private ENDATE = Nothing
    Private STATUS = Nothing
    Private selectPrdprice = "SELECT `prcid` AS 'รหัสรายการราคา', `prdcode` AS 'รหัสสินค้า', `mtrgtid` AS 'หมวดสิทธิ์', `strgtid` AS 'กลุ่มสิทธิ์', `sbrgtid` AS 'ชื่อสิทธิ์', `oprice` AS 'ราคาผู้ป่วยนอก', `iprice` AS 'ราคาผู้ป่วยใน', `stdate` AS 'วันที่เริ่มต้นโปรโมชั่น', `endate` AS 'วันที่สิ้นสุดโปรโมชั่น', `status` AS 'สถานะการเปิดใช้งาน'FROM prdprice"
    'Private selectMasdrgdoswuse = "SELECT USEID, DUCODE, DUSENAME, STATUS FROM masdrgdoswuse"
    'Private selectMasdrgacc = "SELECT DGTYID, DRGTYPE, convert(bit, [STATUS]) FROM MASDRGTYPE"

    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection

    Property PRCID_ As Integer
        Get
            Return PRCID
        End Get
        Set(value As Integer)
            PRCID = value
        End Set
    End Property

    Property PRDCODE_ As Integer
        Get
            Return PRDCODE
        End Get
        Set(value As Integer)
            PRDCODE = value
        End Set
    End Property

    Property MTRGTID_ As Integer
        Get
            Return MTRGTID
        End Get
        Set(value As Integer)
            MTRGTID = value
        End Set
    End Property

    Property STRGTID_ As Integer
        Get
            Return STRGTID
        End Get
        Set(value As Integer)
            STRGTID = value
        End Set
    End Property

    Property SBRGTID_ As Integer
        Get
            Return SBRGTID
        End Get
        Set(value As Integer)
            SBRGTID = value
        End Set
    End Property

    Property OPRICE_ As Integer
        Get
            Return OPRICE
        End Get
        Set(value As Integer)
            OPRICE = value
        End Set
    End Property

    Property IPRICE_ As Integer
        Get
            Return IPRICE
        End Get
        Set(value As Integer)
            IPRICE = value
        End Set
    End Property

    Property STDATE_ As Date
        Get
            Return STDATE
        End Get
        Set(value As Date)
            STDATE = value
        End Set
    End Property

    Property ENDATE_ As Date
        Get
            Return ENDATE
        End Get
        Set(value As Date)
            ENDATE = value
        End Set
    End Property

    Property STATUS_ As Boolean
        Get
            Return STATUS
        End Get
        Set(value As Boolean)
            If value = True Then
                STATUS = 1
            Else
                STATUS = 0
            End If
        End Set
    End Property

    Property selectPrdprice_ As String
        Get
            Return selectPrdprice
        End Get
        Set(value As String)

        End Set
    End Property

    Public Sub DFORMData(ByVal comboboxName As ComboBox)
        Dim masdrgdosageData As DataTable
        masdrgdosageData = connect.GetTable("SELECT DFORM, DOSAGEFORM FROM masdrgdosage")
        Try
            With comboboxName
                .DataSource = masdrgdosageData
                .DisplayMember = "DOSAGEFORM"
                .ValueMember = "DFORM"
                '.BindingContext = BindingContext
            End With
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Public Sub USEIDData(ByVal comboboxName As ComboBox)
        Dim masdrguseData As DataTable
        masdrguseData = connect.GetTable("SELECT USEID, DUSENAME FROM masdrguse")
        Try
            With comboboxName
                .DataSource = masdrguseData
                .DisplayMember = "DUSENAME"
                .ValueMember = "USEID"
                '.BindingContext = BindingContext
            End With
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    'Public Function insertMasdrgdoswuseData()
    '    If TypeOf DFORM Is Integer And TypeOf USEID Is Integer Then
    '        If connect.GetTable("SELECT DUID FROM masdrgdoswuse WHERE DFORM = '" & DFORM & "' AND USEID = '" & USEID & "'").Rows.Count > 0 Then
    '            MsgBox("มีข้อมูลวิธีการใช้ยานี้อยู่ในระบบแล้ว")
    '        Else
    '            Try
    '                connect = CONDB.NewConnection()
    '                'connectlocal = conlocal.NewConnection()
    '                'Dim dischargeID As Integer

    '                connect.ExecuteNonQuery("INSERT INTO masdrgdoswuse (DFORM, USEID, STATUS) VALUES ('" & DFORM & "', '" & USEID & "', '" & STATUS & "')")
    '                'dischargeID = connect.ExecuteScalar("INSERT INTO masdischarge (DISCHARGE, STATUS) VALUES ('" & masdischargeDescription & "', '" & masdischargeStatus & "'); SELECT LAST_INSERT_ID();")
    '                'connectlocal.ExecuteNonQuery("INSERT INTO MASDISCHARGE (DISCHGID, DISCHARGE, STATUS) VALUES ('" & dischargeID & "', '" & masdischargeDescription & "', '" & masdischargeStatus & "')")
    '                MsgBox("ท่านได้ทำการเพิ่มข้อมูลวิธีการใช้ยาเรียบร้อยแล้ว")
    '            Catch ex As Exception
    '                MsgBox(vbCrLf & ex.Message)
    '            End Try
    '            connect.Dispose()
    '            'connectlocal.Dispose()
    '        End If
    '    Else
    '        MsgBox("โปรดกรุณาระบุข้อมูลให้ถูกต้อง")
    '    End If
    'End Function

    'Public Function editMasdrgdoswuseData()
    '    If TypeOf DFORM Is Integer And TypeOf USEID Is Integer Then
    '        Try
    '            connect = CONDB.NewConnection()
    '            'connectlocal = conlocal.NewConnection()

    '            connect.ExecuteNonQuery("UPDATE masdrgdoswuse SET DFORM = '" & DFORM & "', USEID = '" & USEID & "', STATUS = '" & STATUS & "' WHERE DUID = '" & DUID & "'")
    '            'connectlocal.ExecuteNonQuery("UPDATE MASDISCHARGE SET DISCHARGE = '" & masdischargeDescription & "', STATUS = '" & masdischargeStatus & "' WHERE DISCHGID = '" & masdischargeID & "'")
    '            MsgBox("ท่านได้ทำการแก้ไขข้อมูลวิธีการใช้ยาเรียบร้อยแล้ว")
    '        Catch ex As Exception
    '            MsgBox(vbCrLf & ex.Message)
    '        End Try
    '        connect.Dispose()
    '        'connectlocal.Dispose()
    '    Else
    '        MsgBox("โปรดกรุณาระบุข้อมูลให้ถูกต้อง ต้องเป็นตัวอักษร")
    '    End If
    'End Function
End Class